import 'package:flutter/material.dart';
import 'package:flutter_tableview/flutter_tableview.dart';
import 'package:ytbusiness/widgets/widgets.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';

//待结算流水
class FlowTooBeSettled extends StatefulWidget {
  @override
  _FlowTooBeSettledState createState() => _FlowTooBeSettledState();
}

class _FlowTooBeSettledState extends State<FlowTooBeSettled> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(context,title:"待结算流水"),
      body: Container(
        color: Colors.white,
        child: FlutterTableView(
          sectionCount: 3,
          rowCountAtSection: _rowCountAtSection,
          sectionHeaderBuilder: _sectionHeaderBuilder,
          cellBuilder: _cellBuilder,
          sectionHeaderHeight: _sectionHeaderHeight,
          cellHeight: _cellHeight,
        ),
      ),
    );
  }
  int _rowCountAtSection(int section) {
    if (section == 0) {
      return 5;
    } else if (section == 1) {
      return 10;
    } else {
      return 20;
    }
  }
  // Section header widget builder.
  Widget _sectionHeaderBuilder(BuildContext context, int section) {
    return InkWell(
      onTap: () {
        print('区头点击事件!!! section:$section');
      },
      child: Container(
        padding: EdgeInsets.only(left: setWidth(15),),
        color: Color(0xfff0f0f0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Text(
                  '2020年11月',
                  style: TextStyle(
                    color: Color(0xff595959),
                    fontSize: setSp(17),
                  ),
                ),
                SizedBox(
                  width: setWidth(5),
                ),
                Image.asset(
                  'assets/images/downBlack_image.png',
                  width: setWidth(15),
                  height: setWidth(8),
                  fit: BoxFit.fill,
                ),
              ],
            ),
            SizedBox(
              height: setWidth(5),
            ),
            Text(
              '收入￥21897.00  ',
              style: TextStyle(
                color: Color(0xff595959),
                fontSize: setSp(14),
              ),
            ),
          ],
        ),
      ),
    );
  }
  // cell item widget builder.
  Widget _cellBuilder(BuildContext context, int section, int row) {
    return InkWell(
      onTap: () {
        print('cell 点击事件!!! section:$section row:$row');
      },
      child: Container(
        padding: EdgeInsets.only(right: setWidth(15),),
        child: Row(
          children: [
            Image.asset(
              'assets/images/headPortrait_image.png',
              width: setWidth(44),
              height: setWidth(44),
              fit: BoxFit.fill,
            ),
            SizedBox(
              width: setWidth(9),
            ),
            Expanded(
              child: Container(
                height: setWidth(80),
                decoration: BoxDecoration(
                  border: Border(
                    bottom: BorderSide(
                      color: Color(0xffeeeeee),
                      width: setWidth(0.5),
                    ),
                  ),
                ),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Text(
                          '铧丰汽修',
                          style: TextStyle(
                            color: Color(0xff010015),
                            fontSize: setSp(15),
                          ),
                        ),
                        Text(
                          '+3685.00',
                          style: TextStyle(
                            color: Color(0xff1a79ff),
                            fontSize: setSp(15),
                          ),
                        ),
                      ],
                    ),
                    SizedBox(
                      height: setWidth(5),
                    ),
                    Text(
                      '11月1日 12:16',
                      style: TextStyle(
                        color: Color(0xff999999),
                        fontSize: setSp(12),
                      ),
                    ),
                  ],
                ),

              ),
            ),
          ],
        ),
      ),
    );
  }
  // Each section header height;
  double _sectionHeaderHeight(BuildContext context, int section) {
    return setWidth(80);
  }
  // Each cell item widget height.
  double _cellHeight(BuildContext context, int section, int row) {
    return setWidth(80);
  }

}
